import store from "../utils/factory";

//获取应用实例
const app = getApp();

let that = null;

Component({
  data: {
    selected: 3,
    color: "#515863",
    count: 0,
    selectedColor: "#4AB535",
    list: [
      {
        id: 0,
        pagePath: "pages/index/index",
        iconPath: "/images/tab_index_unselected@3x.png",
        selectedIconPath: "/images/tab_index_selected@3x.png",
        text: "天渡配送"
      },
      {
        id: 1,
        pagePath: "pages/classify/classify",
        iconPath: "/images/tab_classify_unselected@3x.png",
        selectedIconPath: "/images/tab_classify_selected@3x.png",
        text: "分类"
      },
      {
        id: 2,
        pagePath: "pages/shopCar/shopCar",
        iconPath: "/images/tab_shopcar_unselected@3x.png",
        selectedIconPath: "/images/tab_shopcar_selected@3x.png",
        text: "购物车"
      },
      {
        id: 3,
        pagePath: "pages/my/my",
        iconPath: "/images/tab_mine_unselected@3x.png",
        selectedIconPath: "/images/tab_mine_selected@3x.png",
        text: "我的"
      }
    ]
  },
  attached() {
    that = this;
  },
  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show: function() {},
    hide: function() {},
    resize: function() {}
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset;
      const url = `/` + data.path;
      wx.switchTab({
        url
      });
      this.setData({
        selected: data.index
      });
    }
  }
});
